home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / old_gen.cpp < prev    next >
C/C++ Source or Header  |  1996-02-15  |  21KB  |  737 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5.  
  6. #include "euro.equ"
  7. #include "euro_def.h"
  8. #include "euro_var.h"
  9. #include "euro_grf.h"
  10. #include "euro_dsk.h"
  11. #include "euro_fix.h"
  12. #include "euro_sel.h"
  13. #include "euro_inf.h"
  14. #include "euro_cnt.h"
  15. #include "euro_usr.h"
  16.  
  17. void    DisplayPositionLabels();
  18. void    DisplaySquad();
  19. void    DisplayFormation( char );
  20. void    ClearFormationMarkers();
  21. short    AddAnimation( int, int, float, float, float, signed char, signed char );
  22. //void    DisplayCountrySelectImages();
  23.  
  24. #include "defines.h"
  25.     extern    "C"    short    MouseBUTTONS;
  26.     extern    int     MouseFlags;
  27.     extern    "C"    short    PaletteFlag;
  28.     extern  int     new_menu;
  29.     extern    "C"    short    MouseDeBOUNCE;
  30.     extern     "C"    short MouseXminimum;           
  31.     extern     "C"    short MouseYminimum;           
  32.  
  33. //********************************************************************************************************************************
  34.  
  35. char    *GetTEXT( short StringNumber )
  36. {
  37.     return( (char *)Text[ StringNumber ] );
  38. }
  39.  
  40. //********************************************************************************************************************************
  41.  
  42. char    *GetTEAMname( char team, char maxlen )
  43.     {
  44.         char    *Name        =    GetTEXT( COUNTRY_NAMES+team );
  45.         char    Searchlen    =    strlen(&Name[0]);
  46.         char    NAMEoffset    =    0;
  47.  
  48.         for ( char x=0; x<Searchlen ; x++ )
  49.             {NameBuffer[x]     = * (Name+x);}
  50.         NameBuffer[x]     = 0;
  51.  
  52.         if ( maxlen!=0 && Searchlen > maxlen )
  53.             {
  54.                 NameBuffer[maxlen-1] = '.';
  55.                 NameBuffer[maxlen] = 0;
  56.             }
  57.  
  58.     return    ( &NameBuffer[0] );
  59.  
  60.     }
  61.  
  62.  
  63.  
  64. //********************************************************************************************************************************
  65.  
  66. char    *GetPLAYERSname( char player, char team, char format )
  67.     {
  68.  
  69.         char    *Search        =    GetTEXT( ( PLAYER_NAMES+(team*20 )+player) );
  70.         char    NAMEoffset    =    0;
  71.         char    Searchlen    =    strlen(&Search[0]);
  72.         
  73.         if ( format == FULL_NAME )
  74.         {    
  75.             for ( char x=0; x < Searchlen ; x++ )
  76.                 {NameBuffer[x]    = *(Search+x);}
  77.             NameBuffer[x]    = 0;
  78.         }
  79.  
  80.  
  81.  
  82.         if ( format == INITIAL_SURNAME )
  83.         {    
  84.             // *** Get players initials ***
  85.         
  86.             for ( char x=0; x < Searchlen ; x++ )
  87.                 {
  88. //                    if ( ( *(Search+x) >= 'A' && *(Search+x) <='Z') && 
  89. //                        ( *(Search+(x+1)) >= 'a' && *(Search+(x+1)) <='z') && NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  90.  
  91.                     if ( IsUpper[ *(Search+x) ] == up && 
  92.                          IsUpper[ *(Search+(x+1)) ] == lw && 
  93.                         NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  94.                     {
  95.                         NameBuffer[NAMEoffset]     = *(Search+x);
  96.                         NAMEoffset++;
  97.         
  98.                         if ((*(Search+x))=='-')
  99.                             NameBuffer[NAMEoffset]     = '-';
  100.                         else                                    
  101.                             NameBuffer[NAMEoffset]     = '.';
  102.         
  103.                         NameBuffer[NAMEoffset+1]     = 32;
  104.                         NAMEoffset+=    2;
  105.                     }
  106.         
  107.                     if ((*(Search+x))=='-' && NAMEoffset >1 )
  108.                     {
  109.                             NameBuffer[NAMEoffset-2]     = '-';
  110.                             NAMEoffset--;
  111.                     }
  112.                 }    
  113.         }
  114.         
  115.         if ( format == INITIAL_SURNAME || format == SURNAME )
  116.         {    
  117.         
  118.             // *** Get players surname ***
  119.         
  120.             for ( char y=0; y < Searchlen ; y++ )
  121.                 {
  122. //                    if ( ( *(Search+y) >= 'A' && *(Search+y) <='Z') && 
  123. //                        ( *(Search+(y+1)) >= 'A' && *(Search+(y+1)) <='Z') && NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  124.  
  125.                     if ( IsUpper[ *(Search+y) ] == up && 
  126.                          IsUpper[ *(Search+(y+1)) ] == up && 
  127.                         NAMEoffset < (NAME_BUFFER_LEN-3) ) 
  128.  
  129.                     {
  130.                         NameBuffer[NAMEoffset]     = *(Search+y);
  131.         
  132. //                        if ( (*(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z' && y>0) &&
  133. //                            (NameBuffer[NAMEoffset-1]!='c' || NameBuffer[NAMEoffset-2]!='M' && NAMEoffset>1 ) 
  134. //                                     ) 
  135.  
  136.                         if ( (IsUpper[ *(Search+(y-1) ) ] == up && y>0) &&
  137.                             (NameBuffer[NAMEoffset-1]!='c' || NameBuffer[NAMEoffset-2]!='M' && NAMEoffset>1 ) )
  138.                             NameBuffer[NAMEoffset]+=    32;
  139.                         NAMEoffset++;
  140.                     }
  141.         
  142.                     else
  143.                     
  144. //                    if ( ( *(Search+y) >= 'A' && *(Search+y) <='Z') && 
  145. //                        ( *(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z') && NAMEoffset < (NAME_BUFFER_LEN-3) && y>0 ) 
  146.  
  147.                         if ( IsUpper[ *(Search+y) ] == up && 
  148.                              IsUpper[ *(Search+(y-1)) ] == up && 
  149.                             NAMEoffset < (NAME_BUFFER_LEN-3) && y>0 ) 
  150.                         {
  151.                             NameBuffer[NAMEoffset]     = *(Search+y);
  152.         
  153. //                            if ( *(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z' && y>0 ) 
  154.  
  155.                             if ( IsUpper[ *(Search+(y-1)) ] == up && y>0 )
  156.                                 NameBuffer[NAMEoffset]+=    32;
  157.         
  158.                             NAMEoffset++;
  159.                     
  160.                                 if ( (*(Search+(y+1)))==' ')
  161.                                 {
  162.                                 NameBuffer[NAMEoffset]     = 32;
  163.                                 NAMEoffset++;
  164.                                 }
  165.                         }
  166.                 }    
  167.  
  168.             NameBuffer[NAMEoffset]    =    0;    // end of line.
  169.         }
  170.  
  171.         return    ( &NameBuffer[0] );
  172.     }
  173.  
  174. //********************************************************************************************************************************
  175.  
  176. void    DisplayString( int xpos, int ypos, char *string, int font, int colour, signed char box, pseudo_info *pseudo, texture_info *texture )
  177.     {
  178.         int c;
  179.         svalue    =    colour;
  180.  
  181.         while    ( c=*(string++) )     
  182.             {
  183.                 if ( c < 127 )
  184.                     c-=    32;
  185.                 else
  186.                      if ( c < 155 )
  187.                         c-=    33;
  188.                     else
  189.                          if ( c < 166 )
  190.                             c-=    38;
  191.                         else
  192.                              if ( c == 225 )
  193.                                 c-=    97;
  194.                             else
  195.                                  if ( c == 237 )
  196.                                      c-=    108;
  197.                 c+=    font;
  198.  
  199.                       DrawIMAGE( pseudo, texture, c, xpos, ypos, box, spriteinccopy );
  200.  
  201.                 xpos+=    (Image_Widths[c])+1;
  202.             }
  203.  
  204.         NextXposn = xpos;
  205.     }
  206.  
  207. //********************************************************************************************************************************
  208.  
  209. int    PixelLengthOfString( char *string, int font )
  210.     {
  211.         int c;
  212.         int    len    =    0;
  213.  
  214.         while    ( c=*(string++) )     
  215.             {
  216.                 if ( c < 127 )
  217.                     c-=    32;
  218.                 else
  219.                      if ( c < 155 )
  220.                         c-=    33;
  221.                     else
  222.                          if ( c < 166 )
  223.                             c-=    38;
  224.                         else
  225.                              if ( c == 225 )
  226.                                 c-=    97;
  227.                             else
  228.                                  if ( c == 237 )
  229.                                      c-=    108;
  230.                 c+=    font;
  231.                 len+=    (Image_Widths[c])+1;
  232.             }
  233.  
  234.     return(len);
  235.  
  236.     }
  237.  
  238. //********************************************************************************************************************************
  239.  
  240. void InitialiseMenuPage( char MENU )
  241.     {
  242.         switch ( MENU )
  243.         {
  244.             case( SQUAD_SELECT ):
  245.                 LoadTactics( ((int)FormationInfo[Team]), &EuroDATfile[0], &TeamTactics[0][0][0] );
  246.                 DisplaySquad();
  247.                 DisplayFormation( NULL );
  248.                 DisplayPositionLabels();
  249.                 MarkPlayer        =    -1;
  250.                 SquadBuffer1yposn    =    -1;
  251.                 QuestionHandle        =     AddAnimation( 488, 16, 
  252.                                  ( (float)QUESTION_MARK ), ( (float)QUESTION_MARK+19.1 ),
  253.                                  0.40, QUESTION_BOX, CONT_ANIM );
  254.                 FormationHandle        =     AddAnimation( NameBarXposn-16, 426,
  255.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  256.                                  0.0, FORMATION_BOX, RUN_ONCE );
  257.                 ReturnSqdHandle        =     AddAnimation( 308, 426,
  258.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  259.                                  0.0, RETURN_SQUAD_BOX, RUN_ONCE );
  260.                 ViewTeamHandle        =     AddAnimation( NameBarXposn-16, 106,
  261.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  262.                                  0.0, OPPONENT_TEAM_BOX, RUN_ONCE );
  263.                 break;
  264.  
  265.             case( GROUP_FIXTURES ):
  266.                 RedrawHandle        =     AddAnimation( 509, 181, 
  267.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  268.                                  0.0, REDRAW_BOX, CONT_ANIM );
  269.                 break;
  270.  
  271.             case( TEAM_SELECT ):
  272.                 ClickBOX        =     NO_BOX;
  273.                 PlayerSetupHandle     =     AddAnimation( 446, 180, 
  274.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  275.                                  0.0, PLAYER_SETUP_BOX, CONT_ANIM );
  276.                 FormationSetupHandle     =     AddAnimation( 446, 228, 
  277.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  278.                                  0.0, FORMATION_SETUP_BOX, CONT_ANIM );
  279.                 SelectionSpeed        =    0;
  280.                 SelectionFlag        =    -1;
  281.                 SelectionAim        =    AimTBL[EUROteamA];
  282.                 SelectionCounter    =    ((float)SelectionAim)*4;
  283.                 DisplayGameType( EUROgameType );
  284.                 DisplayCountrySelectImages();
  285.                 DoFriendlyTeamSelection();
  286.                 break;
  287.  
  288.             case( EURO_REDRAW ):
  289.                 DisplayGroupHeadings();
  290.                 EuroDrawHandle        =     AddAnimation( 179, 234, 
  291.                                  ( (float)EURO_DRAW_ANIM ), ( (float)EURO_DRAW_ANIM+55.0 ),
  292.                                  0.40, QUESTION_BOX, CONT_ANIM );
  293.                 EuroReDrawCounter    =     30.0;
  294.                 EuroReDrawFlag        =    -1;
  295.                 break;
  296.  
  297.             case( PLAYER_STATS ):
  298.                 DisplaySquad();
  299.                 DisplayPositionLabels();
  300.                 QuestionHandle        =     AddAnimation( 488, 16, 
  301.                                  ( (float)QUESTION_MARK ), ( (float)QUESTION_MARK+19.1 ),
  302.                                  0.40, QUESTION_BOX, CONT_ANIM );
  303.                 ReturnStatHandle    =     AddAnimation( 308, 416,
  304.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  305.                                  0.0, RETURN_PSTATS_BOX, CONT_ANIM );
  306.                 DisplayPlayerStats();
  307.                 break;
  308.  
  309.             case( PLAYER_SETUP ):
  310.                 TeamSelectHandle     =     AddAnimation( 516, 434, 
  311.                                  ( (float)BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  312.                                  0.0, TEAM_SELECT_BOX, CONT_ANIM );
  313.                 DisplayMatchTeam( EUROteamA, 87,  0,  16 );
  314.                 DisplayMatchTeam( EUROteamB, 352, 12, 32 );
  315.                 DisplayUserInfo(EUROplyrSetup);
  316.                 break;
  317.                 
  318.             case( TEAM_STATS ):
  319.                 ReturnTeamHandle         =     AddAnimation( 512, 426,
  320.                                  ( (float)BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  321.                                  0.0, RETURN_TSTATS_BOX, CONT_ANIM );
  322.                 ViewTeamHandle        =     AddAnimation( NameBarXposn-16, 106,
  323.                                  ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  324.                                  0.0, OPPONENT_TEAM_BOX, RUN_ONCE );
  325.                 break;
  326.         }
  327.  
  328.         SetupMouseLimits( 0, 626, 1, 452 );
  329.     }
  330.  
  331. //********************************************************************************************************************************
  332.  
  333. void    OverlayStaticBackgroundImages( char MENU )
  334.     {
  335.         int    width;
  336.         
  337.         switch ( MENU )
  338.         {
  339.             case( SQUAD_SELECT ):
  340.  
  341.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  342.                        LION_KITS+Team, 550, 2, NO_BOX, spritecopy );      
  343.                 width       =    PixelLengthOfString( GetTEAMname( Team, 0 ),
  344.                                     LARGE_FONT);
  345.                 Image_Widths[NAMEBAR_LEFT]    =    Image_Widths[NAMEBAR_RIGHT]+width;
  346.  
  347.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  348.                        NAMEBAR_LEFT, NameBarXposn, 
  349.                        106, NO_BOX, spritecopy ); 
  350.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  351.                        NAMEBAR_RIGHT, NameBarXposn+Image_Widths[NAMEBAR_LEFT], 
  352.                        106, NO_BOX, spritecopy );    
  353.  
  354.                 Image_Widths[NAMEBAR_LEFT]    =    FORMATION_BAR_WIDTH;
  355.  
  356.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  357.                        NAMEBAR_LEFT, NameBarXposn, 
  358.                        426, NO_BOX, spritecopy );  
  359.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  360.                        NAMEBAR_RIGHT, NameBarXposn+Image_Widths[NAMEBAR_LEFT], 
  361.                        426, NO_BOX, spritecopy );  
  362.                 DisplayString( NameBarXposn+Image_Widths[NAMEBAR_RIGHT], 110,
  363.                           GetTEXT(Team+COUNTRY_NAMES),
  364.                     LARGE_FONT, 24, TEAM_BOX, &FrontendBackgroundDEFN, &FrontendTextureDEFN  );
  365.                 break;
  366.  
  367.  
  368.             case( GROUP_FIXTURES ):
  369.                 CalculateLeagueTables();
  370.                 DisplayLeagueTables();
  371.                 DisplayLeagueFixtures( MatchNumber );
  372.                 DisplayVersusList();
  373.                 break;
  374.  
  375.             case( TEAM_SELECT ):
  376.                   DisplayLowerSelectionPanel( EUROgameType );        
  377.                 DisplayCountrySelectImages();
  378.                       ReadData( BIN_DRAWPAL, &EuroDATfile[0], &SparePaletteBuffer[0] );
  379.                 memcpy( &PaletteBuffer[44*3], &SparePaletteBuffer[ (LeagueColourOffsets[EUROteamA]*3)+3 ], 7*3 );
  380.                 memcpy( &PaletteBuffer[51*3], &SparePaletteBuffer[ (LeagueColourOffsets[EUROteamB]*3)+3 ], 7*3 );
  381.                 break;
  382.  
  383.             case( PLAYER_STATS ):
  384.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  385.                        LION_KITS+Team, 550, 2, NO_BOX, spritecopy );      
  386.                 break;
  387.                 
  388.             case( PLAYER_SETUP ):
  389.  
  390.                 EUROnoOfMatchPlyrs    =    2;
  391.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  392.                        LION_KITS+EUROteamA, 192, 240, NO_BOX, spritecopy );      
  393.                 svalue    =    16;
  394.                 pmin    =    16;
  395.                 pmax    =    32;
  396.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  397.                        LION_KITS+EUROteamB, 456, 240, NO_BOX, spriteareainccopy );      
  398.                 DisplayUserLabels(EUROplyrSetup);
  399.                 break;
  400.                                 
  401.             case( TEAM_STATS ):
  402.                 width       =    PixelLengthOfString( GetTEAMname( EUROstatTeam, 0 ),
  403.                                     LARGE_FONT);
  404.                 Image_Widths[TSTAT_NAMEBAR_LEFT] =    Image_Widths[TSTAT_NAMEBAR_RIGHT]+width;
  405.  
  406.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  407.                        TSTAT_NAMEBAR_LEFT, NameBarXposn, 
  408.                        106, NO_BOX, spritecopy ); 
  409.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  410.                        TSTAT_NAMEBAR_RIGHT, NameBarXposn+Image_Widths[TSTAT_NAMEBAR_LEFT], 
  411.                        106, NO_BOX, spritecopy );    
  412.                 DisplayString( NameBarXposn+Image_Widths[TSTAT_NAMEBAR_RIGHT], 110,
  413.                           GetTEXT(EUROstatTeam+COUNTRY_NAMES),
  414.                     LARGE_FONT, 36, NO_BOX, &FrontendBackgroundDEFN, &FrontendTextureDEFN  );
  415.  
  416.                 DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, 
  417.                        BIG_COUNTRY_STAT_IMG+EUROstatTeam,
  418.                        TSTATCountryPosnDEFN[EUROstatTeam].xposn,
  419.                        TSTATCountryPosnDEFN[EUROstatTeam].yposn,
  420.                        NO_BOX, spritecopy );    
  421.                 DisplayTeamStats();
  422.                 break;
  423.         }
  424.     }
  425.  
  426. //********************************************************************************************************************************
  427.  
  428. void    SetupExtraTexturePages( int MENU )
  429.     {
  430.         switch ( MENU )
  431.         {
  432.             case( SQUAD_SELECT ):
  433.                 LoadTexturePage( BIN_PAGE2,
  434.                  &EuroDATfile[0],
  435.                  2, &FrontendTextureDEFN );
  436.                 LoadTexturePage( BIN_PAGE3,
  437.                  &EuroDATfile[0],
  438.                  3, &FrontendTextureDEFN );
  439.                     break;
  440.  
  441.             case( TEAM_SELECT ):
  442.                 LoadTexturePage( BIN_PAGE4,
  443.                  &EuroDATfile[0],
  444.                  2, &FrontendTextureDEFN );
  445.                 LoadTexturePage( BIN_PAGE5,
  446.                  &EuroDATfile[0],
  447.                  3, &FrontendTextureDEFN );
  448.                 LoadTexturePage( BIN_PAGE6,
  449.                  &EuroDATfile[0],
  450.                  4, &FrontendTextureDEFN );
  451.                 LoadTexturePage( BIN_PAGE7,
  452.                  &EuroDATfile[0],
  453.                  5, &FrontendTextureDEFN );
  454.                 LoadTexturePage( BIN_PAGE8,
  455.                  &EuroDATfile[0],
  456.                  6, &FrontendTextureDEFN );
  457.                 LoadTexturePage( BIN_PAGE9,
  458.                  &EuroDATfile[0],
  459.                  7, &FrontendTextureDEFN );
  460.                     break;
  461.  
  462.             case( EURO_REDRAW ):
  463.                 LoadTexturePage( BIN_PAGE10,
  464.                  &EuroDATfile[0],
  465.                  2, &FrontendTextureDEFN );
  466.                 LoadTexturePage( BIN_PAGE11,
  467.                  &EuroDATfile[0],
  468.                  3, &FrontendTextureDEFN );
  469.                 LoadTexturePage( BIN_PAGE12,
  470.                  &EuroDATfile[0],
  471.                  4, &FrontendTextureDEFN );
  472.                     break;
  473.  
  474.             case( PLAYER_STATS ):
  475.                 LoadTexturePage( BIN_PAGE2,
  476.                  &EuroDATfile[0],
  477.                  2, &FrontendTextureDEFN );
  478.                 LoadTexturePage( BIN_PAGE13,
  479.                  &EuroDATfile[0],
  480.                  3, &FrontendTextureDEFN );
  481.                     break;
  482.  
  483.             case( PLAYER_SETUP ):
  484.                 LoadTexturePage( BIN_PAGE13,
  485.                  &EuroDATfile[0],
  486.                  3, &FrontendTextureDEFN );
  487.                     break;
  488.  
  489.             case( TEAM_STATS ):
  490.                 LoadTexturePage( BIN_PAGE14,
  491.                  &EuroDATfile[0],
  492.                  4, &FrontendTextureDEFN );
  493.                 LoadTexturePage( BIN_PAGE15,
  494.                  &EuroDATfile[0],
  495.                  5, &FrontendTextureDEFN );
  496.                 LoadTexturePage( BIN_PAGE16,
  497.                  &EuroDATfile[0],
  498.                  6, &FrontendTextureDEFN );
  499.                     break;
  500.         }
  501.     }
  502.  
  503. //********************************************************************************************************************************
  504.  
  505. void    __far EUROinterupt(void)
  506.  
  507.     {
  508.  
  509.     float    red, green, blue;
  510.  
  511.         if ( LogicState == PALETTE_FADEUP )
  512.         {
  513.             if ( FadeCounter < 1 || FadeCounter > FADE_COUNTER )
  514.             {
  515.                 float        *a;
  516.                 BYTE         *Palette;    
  517.                 a        =    &DivisionTable[0];
  518.                 Palette        =    &PaletteBuffer[0];
  519.  
  520.                 FadeCounter      =      FADE_COUNTER;
  521.  
  522.                 for ( int c=0; c < 256; c++ )
  523.                 {
  524.                     red        =    (*(Palette++));        
  525.                     green        =    (*(Palette++));        
  526.                     blue        =    (*(Palette++));        
  527.                     (*(a++))    =    red / FADE_COUNTER;
  528.                     (*(a++))    =    green / FADE_COUNTER;
  529.                     (*(a++))    =    blue / FADE_COUNTER;
  530.                 }
  531.  
  532.                 memset( CurrentPalette, 0, 768 );
  533.             }
  534.     
  535.             float    *a;
  536.             float    *b;
  537.             BYTE     *Palette;    
  538.         
  539.             a        =    &CurrentPalette[0];
  540.             b        =    &DivisionTable[0];
  541.  
  542.             for ( int c=0; c < 256; c++ )
  543.             {
  544.                 red        =    (float) (*(a)) + (*(b++));
  545.                 (*(a++))    =    red;
  546.                 green        =    (float) (*(a)) + (*(b++));
  547.                 (*(a++))    =    green;
  548.                 blue        =    (float) (*(a)) + (*(b++));
  549.                 (*(a++))    =    blue;
  550.                 outp    ( 0x3c8, c );
  551.                 outp    ( 0x3c9, (BYTE) red );
  552.                 outp    ( 0x3c9, (BYTE) green );
  553.                 outp    ( 0x3c9, (BYTE) blue );
  554.             }
  555.         
  556.             FadeCounter--;
  557.     
  558.             if ( FadeCounter < 1 ) 
  559.             {          
  560.                 Palette        =    &PaletteBuffer[0];
  561.                 for ( int c=0; c < 256; c++ )
  562.                        {
  563.                         outp    ( 0x3c8, c );
  564.                         outp    ( 0x3c9, (*( Palette++ ) ) );
  565.                         outp    ( 0x3c9, (*( Palette++ ) ) );
  566.                         outp    ( 0x3c9, (*( Palette++ ) ) );
  567.                     }
  568.  
  569.                 float        *a;
  570.                 BYTE         *Palette;    
  571.                 a        =    &CurrentPalette[0];
  572.                 Palette        =    &PaletteBuffer[0];
  573.  
  574.                 for ( int d=0; d < 256; d++ )
  575.                     {
  576.                         red        =    (*(Palette++));        
  577.                         green        =    (*(Palette++));        
  578.                         blue        =    (*(Palette++));        
  579.                         (*(a++))    =    red;
  580.                         (*(a++))    =    green;
  581.                         (*(a++))    =    blue;
  582.                     }
  583.  
  584.                 LogicState = RUN_FRONTEND;
  585.                 FadeCounter = 0;
  586.             }
  587.         }
  588.  
  589.         else
  590.  
  591.         if ( LogicState == PALETTE_FADEDOWN )
  592.         {
  593.             if ( FadeCounter < 1 || FadeCounter > FADE_COUNTER )
  594.             {              
  595.                 float        *a;
  596.                 float         *Palette;    
  597.                 a        =    &DivisionTable[0];
  598.                 Palette        =    &CurrentPalette[0];
  599.  
  600.                 FadeCounter      =      FADE_COUNTER;
  601.  
  602.                 for ( int c=0; c < 256; c++ )
  603.                 {
  604.                     red        =    (*(Palette++));        
  605.                     green        =    (*(Palette++));        
  606.                     blue        =    (*(Palette++));        
  607.                     (*(a++))    =    red / FADE_COUNTER;
  608.                     (*(a++))    =    green / FADE_COUNTER;
  609.                     (*(a++))    =    blue / FADE_COUNTER;
  610.                 }
  611.             }
  612.  
  613.             float    *a;
  614.             float    *b;
  615.             BYTE     *Palette;    
  616.         
  617.             a        =    &CurrentPalette[0];
  618.             b        =    &DivisionTable[0];
  619.  
  620.             for ( int c=0; c < 256; c++ )
  621.             {
  622.                 red        =    (float) (*(a)) - (*(b++));
  623.                 (*(a++))    =    red;
  624.                 green        =    (float) (*(a)) - (*(b++));
  625.                 (*(a++))    =    green;
  626.                 blue        =    (float) (*(a)) - (*(b++));
  627.                 (*(a++))    =    blue;
  628.                 outp    ( 0x3c8, c );
  629.                 outp    ( 0x3c9, (BYTE) red );
  630.                 outp    ( 0x3c9, (BYTE) green );
  631.                 outp    ( 0x3c9, (BYTE) blue );
  632.             }
  633.         
  634.             FadeCounter--;
  635.     
  636.             if ( FadeCounter < 1 ) 
  637.             {
  638.                 for ( int c=0; c < 256; c++ )
  639.                    {
  640.                     outp    ( 0x3c8, c );
  641.                     outp    ( 0x3c9, 0 );
  642.                     outp    ( 0x3c9, 0 );
  643.                     outp    ( 0x3c9, 0 );
  644.                 }
  645.  
  646.                 memset( CurrentPalette, 0, 768 );
  647.                 FadeCounter     = 0;
  648.                 LogicState     = BLANK_SCREEN;
  649.                 Finish++;
  650.             }
  651.         }
  652.  
  653.         if ( LogicState == RUN_FRONTEND )
  654.                 SelectFrame+=    .55;
  655.         else
  656.                 SelectFrame =    0;
  657.     }
  658.  
  659.  
  660. //********************************************************************************************************************************
  661.  
  662. void    ResetAnimations()
  663.     {
  664.         for ( short a=0; a < MAX_ANIMATIONS; a++ )
  665.         {
  666.             Animation_table[a].StartFrame        =    -1;
  667.             Animation_table[a].EndFrame        =    -1;
  668.             Animation_table[a].Counter        =    0;
  669.             Animation_table[a].AnimationSpeed    =    0;
  670.             Animation_table[a].Bounding_box        =    0;
  671.             Animation_table[a].Flags        =    0;
  672.             Animation_table[a].xposn        =    0;
  673.             Animation_table[a].yposn        =    0;
  674.         }                
  675.     }    
  676.  
  677. //********************************************************************************************************************************
  678.  
  679. short    AddAnimation( int xposn, int yposn, float StartFrame, float EndFrame, float Speed, signed char Box, signed char Flags )
  680.     {
  681.         short    handle    =    0;
  682.  
  683.  
  684.         for ( short a=0; a < MAX_ANIMATIONS; a++ )
  685.         {            
  686.             if ( Animation_table[a].StartFrame==-1 )
  687.             {
  688.                 Animation_table[a].StartFrame        =    StartFrame;
  689.                 Animation_table[a].EndFrame        =    EndFrame;
  690.                 Animation_table[a].AnimationSpeed    =    Speed;
  691.                 Animation_table[a].Bounding_box        =    Box;
  692.                 Animation_table[a].Flags        =    Flags;
  693.                 Animation_table[a].xposn        =    xposn;
  694.                 Animation_table[a].yposn        =    yposn;
  695.                 handle                    =    a;
  696.                 break;
  697.              }
  698.         }
  699.          return(handle);
  700.     }
  701.  
  702. //********************************************************************************************************************************
  703.  
  704. void    ResetBoundingBoxes()
  705.     {
  706.         for ( short b=0; b < MAX_BOUNDING_BOXES; b++ )
  707.         {
  708.             Bounding_table[b].BoundingBoxLeft    =    -1;
  709.             Bounding_table[b].BoundingBoxRight    =    -1;
  710.             Bounding_table[b].BoundingBoxTop    =    -1;
  711.             Bounding_table[b].BoundingBoxBottom    =    -1;
  712.         }                
  713.     }    
  714.  
  715. //********************************************************************************************************************************
  716.  
  717. signed char GetBoundingBox( short xposn, short yposn )
  718.     {
  719.  
  720.     signed char box    =    -1;
  721.  
  722.         for ( int b=0; b < MAX_BOUNDING_BOXES; b++ )
  723.         {
  724.                    if ( xposn > Bounding_table[b].BoundingBoxLeft
  725.                   && xposn < Bounding_table[b].BoundingBoxRight
  726.                           && yposn > Bounding_table[b].BoundingBoxTop
  727.                     && yposn < Bounding_table[b].BoundingBoxBottom)
  728.                         
  729.                     box    =    b;
  730.         }
  731.  
  732.         return(box);
  733.     }
  734.  
  735.                  
  736. //********************************************************************************************************************************
  737.